/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"3AC178E5-13C4-403E-A022-37317EBD24BA",variableType:4}
 */
var mue_subcap = null;

/**
 * Callback method for when form is shown.
 *
 * @param {Boolean} firstShow form is shown first time after load
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"EEB70B5C-D8D2-490B-982E-A4487EB93D02"}
 */
function onShow(firstShow, event) {
	controller.sort("codigo asc")
}

/**
 * Handle changed data.
 *
 * @param {Object} oldValue old value
 * @param {Object} newValue new value
 * @param {JSEvent} event the event that triggered the action
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"36E13760-8AE6-4E6E-9795-D6757CC7583D"}
 */
function onDataChange_codigo(oldValue, newValue, event) {
	if (controller.getSelectedIndex() == 1 && globals.gEstadoAbm == 1)
	{
		elements.nombre.requestFocus()
		return true
	}
	else
	{
		elements.nombre.requestFocus()
		codigo = oldValue
		return true
	}
}

/**
 * @properties={typeid:24,uuid:"0D351B3C-B34F-4226-8299-E9FF606F3CC5"}
 */
function validar() {
	controller.setSelectedIndex(1)
	if (globals.gEstadoAbm == 1)
	{
		var $sql = 'SELECT rubro_id FROM ubicacion WHERE empresa = ? AND capitulo = ? AND codigo = ?'
		var $args = [empresa, codigo]
		var $ds = databaseManager.getDataSetByQuery('contable',$sql,$args,-1)
		if ($ds.getMaxRowIndex() != 0) 
		{		
			return [false,false,"El código ingresado ya existe"]
		}
	}
	return [true]
}

/**
 * @properties={typeid:24,uuid:"96842C96-C4F3-4B76-9511-EA8E79A3B5F0"}
 */
function imprimir()
{
	//forms.ubicaciones_impresion.controller.showPrintPreview()
	jasper('impresion')
}

/**
 * @properties={typeid:24,uuid:"7AFDB3F8-F03F-4FE4-BEF1-A6BB96AC1953"}
 */
function pdf()
{
	//globals.metodoPdf('ubicaciones_impresion','Ubicaciones - ' + globals.glegajo,true)
	jasper('pdf')
}

/**
 * @properties={typeid:24,uuid:"70E3582C-D255-4AC0-BA31-B6126C86C01E"}
 */
function xls()
{
	jasper('xls')
}

/**
 * @properties={typeid:24,uuid:"8801354C-88FD-4A35-A67E-548C035931BC"}
 */
function csv()
{
	jasper('csv')
}

/**
 * @param {String} tipo
 *
 * @properties={typeid:24,uuid:"D20B1226-8CC6-4BBC-8A9F-F00FE2508BD5"}
 */
function jasper(tipo)
{
	var $params = {
		userv: usuarios_to_uservs.razon_social
	}
	var $cols = ['codigo','nombre','vida','ubicacion_to_cuentas.cuenta_impresion','division','centro']
	var $ds	= databaseManager.convertToDataSet(foundset,$cols)
	$ds.setColumnName(3,'cuenta')
	globals.metodoJasper(tipo,'contable/ubicaciones_bienes.jasper','Ubicaciones_Bienes',$ds,$params)
}